package com.scyshkj.university.wechat.wanxiao;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by 唐旭 on 2016/11/20.
 */
@Data
public class WanxiaoAccessToken {
    @JsonProperty("access_token")
    private String accessToken;
    @JsonProperty("expires_in")
    private int expiresIn;
    @JsonProperty("refresh_token")
    private String refreshToken;

    //token创建时间
    private Date createDateTime = new Date();

    /**
     * true:过期<br/>
     * false:未过期
     */
    public boolean expire() {
        Date now = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.SECOND, expiresIn);
        Date time = calendar.getTime();
        return now.after(time);
    }
}
